simulation results/combine results.R

# useful for brining in simulation results that are gathered from the computers
# that use ClusterEvalQ() isntead of mclapply()

# combine for samples
all_samples <-
  results %>%
  transpose() %>%
  map(~ map_dfr(.x, ~ .x$samples))
# combine for intervals
all_intervals <-
  results %>%
  transpose() %>%
  map(~ map_dfr(.x, ~ .x$intervals))
# combine for respective counts
counts <-
  results %>%
  transpose() %>%
  map(~ map(.x, ~ .x$counts)) %>%
  map(~ reduce(.x, `+`)) %>%
  map(~ c(.x[1:3]/5, .x[4:5]))
# combine for proportions
proportions <-
  results[[1]] %>%
  map(~ .x$proportions)

counts
proportions
all_samples
all_intervals

final_results <-
  pmap(
    .l = list(counts, proportions, all_samples, all_intervals),
    ~ list(counts = ..1, proportions = ..2, samples = ..3, intervals = ..4)
  )

final_results %>%
  map_dfr(~ coverage(.x, TRUE)) %>%
  select(-p) %>%
  gather("Interval", "Coverage", -N) %>%
  ggplot(aes(N, Coverage)) +
  geom_path(aes(color = Interval)) +
  geom_hline(yintercept = 0.95, linetype = "dashed") +
  theme_minimal()
BriceonWiley/IntegratedLikelihood.R documentation built on Aug. 21, 2020, 11 p.m.